import request from "@/router/axios";

import {getToken} from "@/util/auth";


/**
 * 文件流返回
 * @param url 接口地址
 */
export const exportBlob = (url) => {
  return request({
    url: url,
    method: 'get',
    responseType: 'blob'
  })
}






export const exportFile = (url,data) => {
  url = url+'?Blade-Auth='+getToken()
  let temp_form = document.createElement("form");
  // 设置form属性
  temp_form.action = url;
  temp_form.target = "_self";
  //temp_form.target = "_blank";
  temp_form.method = "post";
  temp_form.style.display = "none";
  // 处理需要传递的参数
  for (let x in data) {
    let opt = document.createElement("textarea");
    opt.name = x;
    opt.value = data[x];
    temp_form.appendChild(opt);
  }
  document.body.appendChild(temp_form);
  // 提交表单
  temp_form.submit();

}


